import { defineStore } from "pinia";
import { getList } from "../server";
import type { RootObject, Children, ChinaAdd, ChinaTotal } from './type'

export const useMainStore = defineStore('main', {
  state: () => {
    return {
      list: {} as RootObject,
      item: [] as Children[],
      chinaAdd: {} as ChinaAdd,
      chinaTotal: {} as ChinaTotal,
      cityDetail: [] as any
    }
  },
  actions: {
    async getList() {
      const result = await getList()
      this.list = result.data
      this.chinaAdd = this.list.diseaseh5Shelf.chinaAdd
      this.chinaTotal = this.list.diseaseh5Shelf.chinaTotal
      this.cityDetail = this.list.localCityNCOVDataList
    }
  }
})
